<template>
  <div>
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="关键词：">
          <el-input v-model="listPram.name" placeholder="请输入姓名" clearable class="selWidth"/>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click="handleSearch">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="listData.list" v-loading="loading" size="mini" :header-cell-style=" {fontWeight:'bold',background:'#f8f8f9',color: '#515a6e',height:'40px'}" border>
        <el-table-column
          prop="id"
          label="ID"
          width="50"
        />
        <el-table-column label="姓名" prop="name" min-width="100"/>
        <el-table-column label="手机号" prop="mobile" min-width="100"/>
        <el-table-column label="内容" prop="content" min-width="120"/>
        <el-table-column label="创建时间" prop="create_time" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.create_time | filterEmpty }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="140"  fixed="right" align="center">
          <template slot-scope="scope">
            <el-button icon="el-icon-delete" type="danger" size="mini" @click="handlerOpenDel(scope.row)" v-hasPermi="['admin:represent:message:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="listPram.page"
        :page-sizes="constants.page.limit"
        :layout="constants.page.layout"
        :total="listData.count"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>

<script>
import { deleteRepresentMessage, representMessageList } from '@/api/represent'
export default {
  props:['id'],
  data() {
    return {
      constants:this.$constants,
      loading:false,
      listData: { list: [] },
      listPram: {
        name: '',
        page: 1,
        limit: this.$constants.page.limit[0]
      },
    }
  },
  mounted() {
    this.handleGetList()
  },
  methods: {
    close() {
      this.$emit('hideEditDialog')
    },
    handleSearch() {
      this.listPram.page = 1
      this.handleGetList()
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.handleGetList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.handleGetList()
    },
    handlerOpenDel(row) {
      this.$confirm('确认删除当前数据').then(() => {
        deleteRepresentMessage(row.id).then(data => {
          this.$message.success('删除数据成功')
          this.handleGetList()
        })
      })
    },
    resetQuery(){
      this.listPram.name = '';
      this.handleGetList()
    },
    handleGetList() {
      representMessageList( this.listPram ).then(data => {
        this.listData = data
      })
    },
  }
}
</script>

<style scoped lang="scss">
.pictrue{
  width: 150px;
  height: 150px;
  border: 1px dotted rgba(0,0,0,0.1);
  margin-right: 10px;
  position: relative;
  cursor: pointer;
  img{
    width: 100%;
    height: 100%;
  }
  video{
    width: 100%;
    height: 100%;
  }
}
.rich-content{
  width:99%;
  ::v-deep.el-form-item__content{
    margin-left:10px!important;
  }
}
</style>
